package cn.csg.iotplatform.module.system.dal.mysql.userproject;

import java.util.*;

import cn.csg.iotplatform.framework.common.pojo.PageResult;
import cn.csg.iotplatform.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csg.iotplatform.framework.mybatis.core.mapper.BaseMapperX;
import cn.csg.iotplatform.module.system.dal.dataobject.userproject.UserProjectDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csg.iotplatform.module.system.controller.admin.userproject.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户&项目设备授权关系 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface UserProjectMapper extends BaseMapperX<UserProjectDO> {

    default PageResult<UserProjectDO> selectPage(UserProjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserProjectDO>()
                .eqIfPresent(UserProjectDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserProjectDO::getProjectId, reqVO.getProjectId())
                .betweenIfPresent(UserProjectDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserProjectDO::getId));
    }

    List<ProjectVO> getBelongsProjects(@Param("userId") Long userId);

    List<ProjectVO> getAuthProjects(@Param("userId") Long userId);
}